package com.dandelion.admin.dao;

import com.dandelion.admin.criteria.OrderListQueryCriteria;
import com.dandelion.admin.domain.OrderItem;
import com.dandelion.admin.domain.OrderListItem;
import com.rockit.core.pojo.Pagination;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface OrderDao {
    @SelectProvider(type = OrderDaoSqlProvider.class, method = "querySql")
    List<OrderListItem> query(@Param("c") OrderListQueryCriteria criteria, Pagination pagination);

    @SelectProvider(type = OrderDaoSqlProvider.class, method = "countSql")
    int count(@Param("c") OrderListQueryCriteria criteria);

    @SelectProvider(type = OrderDaoSqlProvider.class, method = "queryOrderItemSql")
    List<OrderItem> queryOrderItems(String orderNo);

    @Update("update t_order set expr_status=#{exprStatus} where id=#{orderId}")
    void updateExprStatus(@Param("orderId") Long orderId, @Param("exprStatus") Byte exprStatus);

    @Update("update t_order set expr_status=#{exprStatus}, status=1 where id=#{orderId}")
    void updateExprStatusAndFinished(@Param("orderId") Long orderId, @Param("exprStatus") Byte exprStatus);

    @Update("update t_order set status=2 where id=#{orderId}")
    void orderCancel(Long orderId);
}
